#include <bits/stdc++.h>
using namespace std;
int t;
int car[100010][3],check[100010];
//TempTaTion
int main(){//40pts
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=0;i<t;i++){
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        bool point34=1,point56=1;
        
        for(int j=0;j<n;j++){
            cin>>car[j][0]>>car[j][1]>>car[j][2];
            if(car[j][2]!=0){
                point34=0;
            }
            if(car[j][2]<0){
                point56=0;
            }
        }
        int bestcheck=0;
        for(int j=0;j<m;j++){
            cin>>check[j];
            bestcheck=max(bestcheck,check[j]);
        }
        if(point34){//20 case A
            int cnt=0;
            for(int p=0;p<n;p++){
                if(car[p][1]>v && bestcheck>=car[p][0]){
                    cnt++;
                }
            }

            if(cnt==0) cout<<cnt<<" "<<m<<endl;
            else cout<<cnt<<" "<<m-1<<endl;
            continue;
        }else if(point56){//20 case B
            int cnt=0;
            for(int p=0;p<n;p++){
                if(car[p][0]<=bestcheck){
                    if(v*v<car[p][1]*car[p][1]+2*car[p][2]*(bestcheck-car[p][0])){
                        cnt++;
                    }
                }
            }
            if(cnt==0) cout<<cnt<<" "<<m<<endl;
            else cout<<cnt<<" "<<m-1<<endl;
            continue;
        }else{//20 case smallamount (failed) (spent 1h debug and found fake LOL)
            int lights=0,cnt=0,ove[30][30],bcar[30]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
            for(int p=0;p<m;p++){
                for(int q=0;q<n;q++){
                    ove[p][q]=0;
                    if(car[q][0]<=check[p] && v*v<car[q][1]*car[q][1]+2*car[q][2]*(check[p]-car[q][0])){
                        ove[p][q]=1;
                        //cout<<"A"<<ove[p][q]<<endl;
                        bcar[q]=1;
                    }
                }
            }
            for(int q=0;q<n;q++){
                if(bcar[q]==1)cnt++;
            }
            /*
            for(int p=0;p<m;p++){
                for(int q=0;q<n;q++){
                    cout<<ove[p][q]<<" ";
                }cout<<endl;
            }
            */

            for(int p=0;p<m;p++){
                for(int q=0;q<n;q++){
                    if(ove[p][q]==1){
                        for(int r=p+1;r<m;r++){
                            if(ove[r][q]==1){
                                ove[p][q]=0;
                            }
                        }
                    }
                }
            }
            //
            
            //
            for(int p=0;p<m;p++){
                bool clear=1;
                for(int q=0;q<n;q++){
                    if(ove[p][q]==1){
                        clear=0;
                    }
                }
                if(clear==1){
                    lights++;
                }
            }
            cout<<cnt<<" "<<lights+3<<endl;
        }
    }
    return 0;
}